using HCore.Tests.Runtime.ShootingEditor2D.Scripts.Command;
using HCore.Tests.Runtime.ShootingEditor2D.Scripts.Support;
using UnityEngine;

namespace HCore.Tests.Runtime.ShootingEditor2D.Scripts.ViewController.GamePlay
{
    /// <summary>
    ///     子弹拾取物品类，当玩家碰撞到该物品时会增加子弹数量
    /// </summary>
    public class BulletPickItem : HCoreCommandMonoBehaviour
    {
        /// <summary>
        ///     2D触发器事件回调函数，当其他碰撞体进入该对象的触发器时调用
        /// </summary>
        /// <param name="other">进入触发器的其他碰撞体对象</param>
        private void OnTriggerEnter2D(Collider2D other)
        {
            // 检查碰撞对象是否为玩家
            if (other.CompareTag("Player"))
            {
                // 发送增加子弹命令
                SendCommand(new AddBulletCommand());
                // 销毁当前游戏对象
                Destroy(gameObject);
            }
        }
    }
}